package org.mspring.mlog.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Gao Youbo
 * @since 2013-2-19
 */
@Entity
@Table(name = "attachment")
public class Attachment implements Serializable {

    private static final long serialVersionUID = 8262841998174621076L;

    private Long id;
    private String url;
    private long size;
    private long user;
    private long foreignKey;
    private String foreignType; // 附件来源
    private Date createTime;

    public Attachment() {
    }

    public Attachment(Long id) {
        super();
        this.id = id;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(unique = true, nullable = false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(nullable = false)
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Column
    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

    @Column
    public long getUser() {
        return user;
    }

    public void setUser(long user) {
        this.user = user;
    }

    @Column(nullable = false)
    public long getForeignKey() {
        return foreignKey;
    }

    public void setForeignKey(long foreignKey) {
        this.foreignKey = foreignKey;
    }

    @Column(nullable = false)
    public String getForeignType() {
        return foreignType;
    }

    public void setForeignType(String foreignType) {
        this.foreignType = foreignType;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * 附件来源
     *
     * @author Gao Youbo
     * @since 2013-5-23
     */
    public static final class AttachFrom {
        public static final String FROM_POST = "POST"; // 文章
        public static final String FROM_TWITTER = "TWITTER"; // 叨叨
        public static final String FROM_METAWEBLOG = "METAWEBLOG"; // metaweblog
    }

}
